import React from 'react';
import {connect} from 'dva';
// import 'bootstrap/dist/css/bootstrap.min.css';

const Count = ({count, dispatch}) => {
    return (
        <div className="container alert">
            <h1>计数器</h1>
            <hr />
            <div className="btn-group" role="group">
                <div className="btn-group" role="group">
                    <button type="button" className="btn btn-default" onClick={() => { dispatch({type: 'count/minus',data:2}); }}>-</button>
                </div>
                <div className="btn-group">
                    <button className="btn btn-default"> {count.record} </button>
                </div>
                <div className="btn-group" role="group">
                    <button type="button" className="btn btn-default" onClick={() => { dispatch({type: 'count/add',data:3}); }}>+</button>
                </div>
                <div className="btn-group" role="group">
                    <button type="button" className="btn btn-default" onClick={()=>dispatch({type:'count/addAsync'})}>异步+</button>
                </div>
            </div>
        </div>
    )
}

Count.propsTypes = {

}

const mapStateToProps=(state)=>{
    return {
        count: state.count
    }
}
export default connect(mapStateToProps)(Count);